<?php
class lappettycash_model extends CI_Model{
	private $Kdtransaksi;
	private $Kodepettycash;
	private $namapettycash;
	private $Tanggal;
	private $Keterangan;
	private $Amount;
    private $Createdby;
    private $Createdon;
    private $Lastupdateby;
  	private $Lastupdateon;
  	private $Active;
	
	private $tglAkhir;
	private $tglAwal;
	
	function setKdtransaksi($kdtrans){
		$this->Kdtransaksi = $kdtrans;
	}
	function getKdtransaksi(){
		return $this->Kdtransaksi;
	}
	
	function setKodepettycash($kdpetty){
		$this->Kodepettycash = $kdpetty;
	}
	function getKodepettycash(){
		return $this->Kodepettycash;
	}
	
	function setnamapettycash($kdpetty){
		$this->namapettycash = $kdpetty;
	}
	function getnamapettycash(){
		return $this->namapettycash;
	}
	
	function setTanggal(){
		$dateNow = date('Y-m-d');
		$this->Tanggal = $dateNow;
	}
	function getTanggal(){
		return $this->Tanggal;
	}

	function setKeterangan($ket){
		$this->Keterangan = $ket;
	}
	function getKeterangan(){
		return $this->Keterangan;
	}
	
	function setAmount($amount){
		$this->Amount = $amount;
	}
	function getAmount(){
		return $this->Amount;
	}
	
	function setCreatedBy($c_by){
		$this->CreatedBy = $c_by;
	}
	function getCreatedBy(){
		return $this->CreatedBy;
	}

	function setCreatedOn(){
		$dateNow = date('Y-m-d H:i:s');
		$this->Createdon = $dateNow;
	}
	function getCreatedOn(){
		return $this->Createdon;
	}

	function setLastUpdateBy($u_by){
		$this->Lastupdateby = $u_by;
	}
	function getLastUpdateBy(){
		return $this->Lastupdateby;
	}
	
	function setLastUpdateOn(){
		$dateNow = date('Y-m-d H:i:s');
		$this->Lastupdateon = $dateNow;
	}
	function getLastUpdateOn(){
		return $this->Lastupdateon;
	}

	function setActive($active_val){
		$this->Active = $active_val;
	}
	function getActive(){
		return $this->Active;
	}
	
	function setTanggalAwal($tglAwal){
		$this->tglAwal = $tglAwal;
	}
	function getTanggalAwal(){
		return $this->tglAwal;
	}
	
	function setTanggalAkhir($tglAkhir){
		$this->tglAkhir = $tglAkhir;
	}
	function getTanggalAkhir(){
		return $this->tglAkhir;
	}
	
	// Call the module constructor
	function __construct(){
		parent::__construct();
	}
	
	function getList(){
		$tanggal=date('Y-m-d', strtotime('now'));
		$this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
			->where(array('transaksi_petty_cash.Tanggal' => $tanggal,'transaksi_petty_cash.Active'=>'1'));
        $query = $this->db->get('transaksi_petty_cash');
        return $query->result();
	}
	
	function getListtanggal() 
	{
		$tglawl 	= date('Y-m-d', strtotime($this->getTanggalAwal()));
		$tglakhr	= date('Y-m-d', strtotime($this->getTanggalAkhir()));

		$query = $this->db->query("select A.Kdtransaksi,A.Tanggal,A.Kodepettycash,B.namapettycash,A.Keterangan,A.Amount,
A.CreatedBy from transaksi_petty_cash A,master_petty_cash B
where A.Kodepettycash=B.Kodepettycash and A.Active='1' and A.Tanggal between '".$tglawl."' and '".$tglakhr."'");
		/*
        $this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")
		->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
		->where ('transaksi_petty_cash.Tanggal BETWEEN '.$tglawl.' AND '.$tglakhr.'');
        $query = $this->db->get('transaksi_petty_cash');*/
        return $query->result();
    }
	
	function getkdtranslike(){
		$this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
		->where(array('transaksi_petty_cash.Active'=>'1'))->like(array('transaksi_petty_cash.Kdtransaksi' => $this->getKdtransaksi()));
		$query = $this->db->get('transaksi_petty_cash');
		return $query->result();
	}
	
	function getkdpettylike(){
		$this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
		->where(array('transaksi_petty_cash.Active'=>'1'))->like(array('transaksi_petty_cash.Kodepettycash' => $this->getKodepettycash()));
		$query = $this->db->get('transaksi_petty_cash');
		return $query->result();
	}
	
	function getnamapettylike(){
		$this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
		->where(array('transaksi_petty_cash.Active'=>'1'))->like(array('master_petty_cash.namapettycash' => $this->getnamapettycash()));
		$query = $this->db->get('transaksi_petty_cash');
		return $query->result();
	}
	
	function getketpettylike(){
		$this->db->select("transaksi_petty_cash.Kdtransaksi,transaksi_petty_cash.Tanggal,transaksi_petty_cash.Kodepettycash,master_petty_cash.namapettycash,transaksi_petty_cash.Keterangan,transaksi_petty_cash.Amount,transaksi_petty_cash.CreatedBy")->join('master_petty_cash', 'master_petty_cash.Kodepettycash=transaksi_petty_cash.Kodepettycash')
		->where(array('transaksi_petty_cash.Active'=>'1'))->like(array('transaksi_petty_cash.Keterangan' => $this->getKeterangan()));
		$query = $this->db->get('transaksi_petty_cash');
		return $query->result();
	}
}